import React from 'react';
import { ListView, Icon, Badge } from 'antd-mobile';
import date from '../../../../../../framework/utils/date';
import avatar from '../../../../../../framework/utils/avatar';
import defaultImg from '../../../../../../assets/avatar.jpg';
import styles from './myEducationList.css';

import MyPartTimeItem from './MyEducationItem/MyEducationItem';

const MyEducationList = ({
  loading,
  list=[],
  onPutEducation=()=>{},
  onPagination=()=>{},
  showLimit=()=>{},
  addEducation=()=>{},
}) => {
  console.log('loading',loading);
  console.log('教育经历list',list);

  const dataSource = new ListView.DataSource({
    rowHasChanged: (row1, row2) => row1 !== row2,
  });

  const separator = (sectionID, rowID) => (
      <div key={`${sectionID}-${rowID}`} className={styles.separator} />
    );

  const row = (item) => {
    const itemPros = {
      // item,
      // onViewMember,
      // onPagination,
      // showLimit,
    }
    return <MyPartTimeItem {...itemPros}/>
  };

  const loadView = () => {
    return (
      <div style={{ padding: 6, textAlign: 'center' }}>
        {loading ? '加载中...' : loaded()}
      </div>
    )
  }

  const loaded = () =>{
    // console.log('list',JSON.stringify(list));
    if(list && JSON.stringify(list) != '{}' && JSON.stringify(list) != '[]'){
      return '加载完成';
    }else{
      return '暂无信息';
    }
  }


  return (
    <div className={styles.container}>
      <div className={styles.addDIV} onClick={addEducation}> + 添加教育经历</div>
      <div className={styles.normal}>
        <ListView
          dataSource={dataSource.cloneWithRows(list)}
          renderFooter={() => loadView()}
          renderRow={row}
          renderSeparator={separator}
          pageSize={4}
          useBodyScroll
          onScroll={() => { }}
          scrollRenderAheadDistance={500}
          scrollEventThrottle={200}
          onEndReachedThreshold={10}
          onEndReached={() => onPagination()}
        />
      </div>

    </div>
  );
};

MyEducationList.propTypes = {
};

export default MyEducationList;
